package lockDemo.synchronizeDemo;

import java.util.concurrent.TimeUnit;

/**
* @author jie
* @version 创建时间：2017年12月6日 下午8:57:05
* 类说明
*/
public class Demo2 {
	public static void main(String[] args) {
		Demo2 demo2 = new Demo2();
		demo2.f();
//		c();
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				System.out.println("1111");
				try {
					TimeUnit.SECONDS.sleep(10);
					demo2.f();
					System.out.println("1111_________");
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		}).start();
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				System.out.println("22222");
				try {
					TimeUnit.SECONDS.sleep(10);
					demo2.f();
					System.out.println("22222__________");
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		}).start();
	}
	
	private synchronized void f() {
		System.out.println("fff");
		g();
	}
	
	private synchronized void g() {
		System.out.println("gggg");
	}
	
	private static synchronized void c() {
		System.out.println("ccc");
		d();
	}
	
	private static synchronized void d() {
		System.out.println("ddd");
		e();
	}
	private static synchronized void e() {
		System.out.println("eee");
		
	}
}
